#ifndef XL_UPLOADER_UPLOADER
#define XL_UPLOADER_UPLOADER
#include <Windows.h>

class CMainWindow;
class CUploader
{
	// static CUploader     *m_instance;
	static const int      MAX_THREAD_COUNT = 10;
	HANDLE                m_threadHandles[MAX_THREAD_COUNT];

	HANDLE                m_semaphore;
	CRITICAL_SECTION      m_cs;

	int                   m_countThreadWillUse;
	int                   m_countThreadWorking;
	bool                  m_userCancel;
	bool                  m_exiting;

	CMainWindow          *m_pMainWindow;

	static unsigned __stdcall _UploadThread(void *);
	static int _ProgressCallback(
	                             void *clientp,
	                             double dltotal,
	                             double dlnow,
	                             double ultotal,
	                             double ulnow
	                             );

	CUploader(void);
	~CUploader(void);

public:
	static CUploader* getInstance();
	int getWorkingThreadCount() const { return m_countThreadWorking; }

	bool startUpload();
	bool stopUpload();
	void resetUserCancel();
};

#endif // XL_UPLOADER_UPLOADER
